import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      requiresAuth: true // 用于判断进入这个路由是否需要认证
    }
  },
  {
    path: '/about',
    name: 'About',
    meta: {
      requiresAuth: true // 用于判断进入这个路由是否需要认证
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/About.vue')
  },
  {
    path: '/login',
    name: 'Login',
    meta: {
      requiresAuth: false // 用于判断进入这个路由是否需要认证
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/Login.vue')
  }
]

const router = new VueRouter({
  mode:'hash',
  base:process.env.BASE_URL,
  routes
})

export default router
